import java.util.ArrayList;

import javax.media.opengl.GL2;

import builder.Face;
import builder.FaceVertex;
import builder.VertexGeometric;
import builder.VertexNormal;


public class ObjData {
	public ArrayList<float[]> vertices = null;
	public ArrayList<float[]> normals = null;
	
	public ObjData(){
		vertices = new ArrayList<float[]>();
		normals = new ArrayList<float[]>();
	}
	
	public void getMainObject(){
		ArrayList<Face> faces = Controller.builder.faces;
		//ArrayList<VertexGeometric> verts = Controller.builder.verticesG;
		//ArrayList<VertexNormal> norms = Controller.builder.verticesN;	
		System.out.println(faces.size());
		for (int i=0; i< 1300; i++){
			vertices.add(faces.get(i).vertices.get(0).v.toFloat());
			normals.add(faces.get(i).vertices.get(0).n.toFloat());
			vertices.add(faces.get(i).vertices.get(1).v.toFloat());
			normals.add(faces.get(i).vertices.get(1).n.toFloat());
			vertices.add(faces.get(i).vertices.get(2).v.toFloat());
			normals.add(faces.get(i).vertices.get(2).n.toFloat());
		}
		//System.out.println("here");
	}
	
	public static void castFromVertexGeometric(ArrayList<float[]> flst, ArrayList<VertexGeometric> glst){
		for (int i=0; i< glst.size(); i++){
			flst.add(glst.get(i).toFloat());
		}
	}
	
	public static void castFromVertexNormal(ArrayList<float[]> flst, ArrayList<VertexNormal> nlst){
		for (int i=0; i< nlst.size(); i++){
			flst.add(nlst.get(i).toFloat());
		}
	}
	
	
	public static ObjData getRoom(){
		ObjData room = new ObjData();
		float[][] normals = { {0,0,0},
				{0.0f,1.0f,0.0f}, {0.0f,0.0f,-1.0f}, {0.0f,0.0f,1.0f}, {0.0f,1.0f,0.0f},
				{1.0f,0.0f,0.0f}, {1.0f,0.0f,0.0f} 
		};
    	float[][] points = { {0,0,0},
				{0.4f,0.4f,0.4f} ,	{-0.4f,0.4f,0.4f} ,	{0.4f,0.4f,0.1f} ,	{0.1f,0.4f,0.1f} ,
				{-0.1f,0.4f,0.1f} ,	{-0.4f,0.4f,0.1f} ,	{0.1f,0.4f,-0.1f} ,	{-0.1f,0.4f,-0.1f} ,
				{0.4f,0.4f,-0.8f} ,	{0.1f,0.4f,-0.8f} ,	{-0.1f,0.4f,-0.8f} ,	{-0.4f,0.4f,-0.8f} ,
				{0.4f,-0.4f,0.4f} ,	{0.4f,-0.4f,-0.8f} ,	{-0.4f,-0.4f,-0.8f} ,	{-0.4f,-0.4f,0.4f} ,
    	};
    	// ceiling

    	for (int i=0 ; i<24; i++) {
    		room.normals.add(normals[1]);
    	}
    	
    	room.vertices.add(points[1]);room.vertices.add(points[3]);room.vertices.add(points[2]);
    	room.vertices.add(points[3]);room.vertices.add(points[6]);room.vertices.add(points[2]);
    	room.vertices.add(points[3]);room.vertices.add(points[9]);room.vertices.add(points[4]);
    	room.vertices.add(points[9]);room.vertices.add(points[10]);room.vertices.add(points[8]);
    	room.vertices.add(points[7]);room.vertices.add(points[10]);room.vertices.add(points[8]);
    	room.vertices.add(points[8]);room.vertices.add(points[10]);room.vertices.add(points[11]);
    	room.vertices.add(points[11]);room.vertices.add(points[12]);room.vertices.add(points[5]);
    	room.vertices.add(points[5]);room.vertices.add(points[12]);room.vertices.add(points[6]);

    	//back wall
  
    	for (int i=0 ; i<6; i++){
    		room.normals.add(normals[2]);
    	}
    	room.vertices.add(points[2]);room.vertices.add(points[1]);room.vertices.add(points[16]);
    	room.vertices.add(points[1]);room.vertices.add(points[13]);room.vertices.add(points[16]);
    	
    	//front wall

    	for (int i=0 ; i<6; i++) {
    		room.normals.add(normals[3]);
    	}
    	room.vertices.add(points[9]);room.vertices.add(points[14]);room.vertices.add(points[15]);
    	room.vertices.add(points[12]);room.vertices.add(points[9]);room.vertices.add(points[15]);
    	
    	//floor

    	for (int i=0; i<6; i++){
    		room.normals.add(normals[4]);
    	}
    	room.vertices.add(points[16]);room.vertices.add(points[13]);room.vertices.add(points[15]);
    	room.vertices.add(points[13]);room.vertices.add(points[14]);room.vertices.add(points[15]);
    	
    	//left wall
    	for (int i=0 ; i<6; i++) {
    		room.normals.add(normals[5]);
    	}
    	room.vertices.add(points[1]);room.vertices.add(points[13]);room.vertices.add(points[9]);
    	room.vertices.add(points[13]);room.vertices.add(points[14]);room.vertices.add(points[9]);

    	//right wall
    	for (int i=0 ; i<6; i++){
    		room.normals.add(normals[6]);
    	}
    	room.vertices.add(points[2]);room.vertices.add(points[16]);room.vertices.add(points[12]);
    	room.vertices.add(points[12]);room.vertices.add(points[16]);room.vertices.add(points[15]);
    	
    	return room;
	}
}